<?php

declare(strict_types=1);

namespace DreamCat\Psr4Laravel\Provider;

use DreamCat\Psr4Laravel\Factory\LaravelRequestFactory;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;
use Psr\Http\Message\RequestInterface;

/**
 * Psr请求提供器
 * @author vijay
 */
class PsrRequestProvider extends ServiceProvider
{
    /**
     * @inheritDoc
     * @noinspection PhpMissingParentCallCommonInspection
     */
    public function register(): void
    {
        $this->app->bind(RequestInterface::class, function () {
            $request = $this->app->make(Request::class);
            return $this->app
                ->make(LaravelRequestFactory::class)
                ->create($request);
        });
    }
}

# end of file
